"""hf_mall URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path, include
from rest_framework.documentation import include_docs_urls
from rest_framework.routers import DefaultRouter

import xadmin
from goods.views import CategoryListViewSet, GoodsListViewSet, GoodViewSet, RecommendListViewSet
from operation.views import UserFavViewset, AddressViewset
from trade.views import ShoppingCartViewset, OrderViewSet, AlipayView
from users.views import SmsCodeViewset, UserViewset
from utils.custom_token import obtain_jwt_token

router = DefaultRouter()
# 注册goods下的路由
router.register('categories', CategoryListViewSet, basename='categories')
router.register('good-list', GoodsListViewSet, basename='good-list')
router.register('recommend-list', RecommendListViewSet, basename='recommend-list')
router.register('good', GoodViewSet, basename='good')
router.register('register-code', SmsCodeViewset, basename='register-code')
router.register('users', UserViewset, basename='users')
router.register('collections', UserFavViewset, basename='collections')
router.register('address', AddressViewset, basename='address')
router.register('shopping-carts', ShoppingCartViewset, basename='shopping-carts')
router.register('orders', OrderViewSet, basename='orders')

urlpatterns = [
    path('xadmin/', xadmin.site.urls),
    path('api-auth/', include('rest_framework.urls')),
    path('docs/', include_docs_urls(title="HF商城")),
    path('', include(router.urls)),
    path('login/', obtain_jwt_token),
    path('alipay/return/', AlipayView.as_view(), name="alipay"),
]
